package zjh_20230403;

import java.io.*;

public class exam03 {
    public static void main(String[] args) {
        File file = new File("D:\\kaifamiao\\project\\homeWork_20230221");
        File file1 = new File("D:\\kaifamiao\\project\\homeWorknew_20230221");
        if (!file1.exists()){
            file1.mkdirs();
        }
        File[] files = file.listFiles(f->{
            return f.getName().endsWith(".java");
        });
        for (File f : files) {
            File file2 = new File(file1 , file1.getName());
            try {
                FileInputStream ios = new FileInputStream(f);
                FileOutputStream os = new FileOutputStream(file2);
                byte[] bytes = ios.readAllBytes();
                os.write(bytes);
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }

    }
}
